import java.util.Timer;
import java.util.TimerTask;

public class Test {
    public static void main(String[] args) {
        MyTimer myTimer = new MyTimer();
        MyTimerTask task1 = new MyTimerTask() {
            public void run() {
                System.out.println("MyTask1");
            }
        };

        MyTimerTask task2 = new MyTimerTask() {
            public void run() {
                System.out.println("MyTask2");
            }
        };

        MyTimerTask task3 = new MyTimerTask() {
            public void run() {
                System.out.println("MyTask3");
            }
        };
        myTimer.schedule(task1, 3000);
        myTimer.schedule(task2, 2000);
        myTimer.schedule(task3, 1000);
    }
    public static void main1(String[] args) {
        Timer timer = new Timer();
        TimerTask task = new TimerTask() {
            @Override
            public void run() {
                System.out.println("执行了task");
            }
        };
        System.out.println("调用schedule");
        timer.schedule(task, 3000);
        timer.cancel();
    }
}
